#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() {
    int a, b, c, d, x, aa, bb, cc, dd;
    int A = 0, B = 0;
    srand(time(0));
    a = rand() % 10;
    b = rand() % 10;
    while (b == a) b = rand() % 10;
    c = rand() % 10;
    while (c == a || c ==b) c = rand() % 10;
    d = rand() % 10;
    while (d == a || d == b || d == c) d = rand() % 10;
    while (A != 4) {
        A = 0;
        B = 0;
        scanf("%d", &x);
        while (1) {
            if (x >= 123 && x <= 9876) {
                aa = x / 1000;
                bb = (x / 100) % 10;
                cc = (x % 100) / 10;
                dd = x % 10;
                if (aa - bb && aa - cc && aa - dd && bb - cc && bb - dd && cc - dd) break;
            }
            printf("Error!\n");
            scanf("%d", &x);
        }
        if (aa == a) ++A;
        else if (aa == b || aa == c || aa == d) ++B;
        if (bb == b) ++A;
        else if (bb == a || bb == c || bb == d) ++B;
        if (cc == c) ++A;
        else if (cc == a || cc == b || cc == d) ++B;
        if (dd == d) ++A;
        else if (dd == a || dd == b || dd == c) ++B;
        printf("%dA%dB\n", A, B);
    }
    return 0;
}